package com.ghn.cocknovel.ui.activity.more.vm

import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.example.basemodel.base.BaseViewModel
import com.ghn.cocknovel.net.DataService
import com.ghn.cocknovel.ui.activity.main.vm.MainViewModel
import com.kt.NetworkModel.bean.CumulativeBean
import com.kt.NetworkModel.bean.CumulativenduartionBean
import com.kt.NetworkModel.bean.OnlineBean
import com.kt.NetworkModel.bean.ScorestatisticsBean
import com.kt.NetworkModel.net.CallBack
import com.kt.NetworkModel.net.RxUtils

/**
 * @author 浩楠
 *
 * @date 2023/10/10-16:02.
 *
 *      _              _           _     _   ____  _             _ _
 *     / \   _ __   __| |_ __ ___ (_) __| | / ___|| |_ _   _  __| (_) ___
 *    / _ \ | '_ \ / _` | '__/ _ \| |/ _` | \___ \| __| | | |/ _` | |/ _ \
 *   / ___ \| | | | (_| | | | (_) | | (_| |  ___) | |_| |_| | (_| | | (_) |
 *  /_/   \_\_| |_|\__,_|_|  \___/|_|\__,_| |____/ \__|\__,_|\__,_|_|\___/
 * @Description: TODO
 */
open class MoreViewModel(application: Application) : BaseViewModel(application) {
    companion object {
        val TAG: String? = MainViewModel::class.simpleName
    }
    val onlinetime = MutableLiveData<OnlineBean?>()
    val cumulative= MutableLiveData<CumulativeBean?>()
    val cumulativenduartion= MutableLiveData<CumulativenduartionBean?>()
    val scorestatistics= MutableLiveData<ScorestatisticsBean?>()
    /**
     *  在线时常
     */
    open fun getonlinetime() {
        DataService.getonlinetime().compose(RxUtils.mainSync())
            .subscribe(object : CallBack<OnlineBean>() {
                override fun onResult(result: OnlineBean?) {
                    result?.also {
                        onlinetime.value = it
                    }
                }
            })
    }
    /**
     *  周月累计时长统计
     */
    open fun getcumulativenduartion() {
        DataService.getcumulativenduartion().compose(RxUtils.mainSync())
            .subscribe(object : CallBack<CumulativenduartionBean>() {
                override fun onResult(result: CumulativenduartionBean?) {
                    result?.also {
                        cumulativenduartion.value = it
                    }
                }
            })
    }

    /**
     *  累计订单数统计
     */
    open fun getcumulative() {
        DataService.getcumulative().compose(RxUtils.mainSync())
            .subscribe(object : CallBack<CumulativeBean>() {
                override fun onResult(result: CumulativeBean?) {
                    result?.also {
                        cumulative.value = it
                    }
                }
            })
    }
    /**
     *  周/月评分
     */
    open fun getscorestatistics() {
        DataService.getscorestatistics().compose(RxUtils.mainSync())
            .subscribe(object : CallBack<ScorestatisticsBean>() {
                override fun onResult(result: ScorestatisticsBean?) {
                    result?.also {
                        scorestatistics.value = it
                    }
                }
            })
    }

}